package editAir.buildEdit.ui.buildList
{
	import _me.Scene_data;
	
	import com.net.AssetData;
	import com.ui.cell.Cell;
	import com.ui.cell.CellData;
	import com.ui.controls.Button;
	import com.ui.data.ButtonData;
	
	import editAir.buildEdit.BuildEditDisplay3DSprite;
	import editAir.buildEdit.BuildEditEvent;
	import editAir.buildEdit.BuildEditEventVO;
	import editAir.buildEdit.EditManage;
	
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import robotleMvc.ui.SkinType;
	import robotleMvc.ui.TextUtil;
	import robotleMvc.ui.UIUtil;
	


	
	public class BuildEditListCell extends Cell
	{
		private var _makeShadowBut:Button;
		private var _buildName:TextField;
		private var _statVO:BuildEditDisplay3DSprite;
		private var _buildX:TextField;
		private var _buildZ:TextField;
		private var _chooseBut:Button;
		
		public function BuildEditListCell(data:CellData)
		{
			super(data);
			addTexts();
			addButtons();
			addEvents();
		}
		
		private function addEvents():void
		{
			_makeShadowBut.addEventListener(MouseEvent.MOUSE_DOWN,_makeShadowButClik);
			_chooseBut.addEventListener(MouseEvent.MOUSE_DOWN,_chooseButDown)
		}
		
		protected function _chooseButDown(event:MouseEvent):void
		{
			var evtVo:BuildEditEventVO=new BuildEditEventVO;
			evtVo.eventID=BuildEditEvent.BUILD_EDIT_LIST_CELL_CLIK;
			EditManage.notChangeOther=!EditManage.notChangeOther;
			if(EditManage.notChangeOther){
				_chooseBut.htmlText="撤";
				evtVo.source=_statVO;
				
				 Scene_data.focus3D.x=_statVO.x;
				 Scene_data.focus3D.z=_statVO.z;
			}else{
				_chooseBut.htmlText="选";
				evtVo.source=null;
			}
			EditManage.sendEvent(evtVo); 
			
		}
		
		protected function _makeShadowButClik(event:MouseEvent):void
		{
		
			/*
			var evtVo:BuildEditEventVO=new BuildEditEventVO;
			evtVo.eventID=BuildEditEvent.OPEN_CAN_EDIT_OBJ;
			evtVo.source=_statVO;
			EditManage.sendEvent(evtVo); 
			
			*/
			if(_statVO.isCanMove){
				_statVO.isChoose=false;
				_statVO.isCanMove=false;
				_makeShadowBut.htmlText="锁";
			}else{
				_statVO.isCanMove=true;
				_makeShadowBut.htmlText="开";
			}
	
		}
		
		private function addTexts():void
		{
			_buildName=TextUtil.getTextField();
			_buildName.x=10;
			_buildName.y=3;
			addChild(_buildName);
			
			_buildX=TextUtil.getTextField();
			_buildX.x=70;
			_buildX.y=3;
			addChild(_buildX);
			
			_buildZ=TextUtil.getTextField();
			_buildZ.x=140
			_buildZ.y=3;
			addChild(_buildZ);
		}
		
		private function addButtons():void
		{
	
			_makeShadowBut=UIUtil.addButton(this,290,2,25,25,"开")
			_chooseBut=UIUtil.addButton(this,255,2,25,25,"撤")
		}
		override public function set source(value:*):void
		{
			_source=value;
			_statVO=value as BuildEditDisplay3DSprite
			if (_statVO)
			{
				if(_statVO.isCanMove){
					_makeShadowBut.htmlText="开";
				}else{
					_makeShadowBut.htmlText="锁";
				}
				_buildName.htmlText=String(_statVO.name);
				_buildX.htmlText=String(int(_statVO.x));
				_buildZ.htmlText=String(int(_statVO.z));
			}
		}
	}
}
